<?php
namespace app\controller;

use think\facade\Db;
use think\facade\View;

class Index extends Base
{
    public function index()
    {
        $where = [
            ['status','=',1]
        ];
        $menus = Db::table('admin_sys_menu')->where($where)->order('type,sort desc')->select()->toArray();
        $tree = [];
        foreach ($menus as $menus_v){
            if($menus_v['parent_id'] == 0){
                $tree[$menus_v['menu_id']] = $menus_v;
            }else{
                $tree[$menus_v['parent_id']]['child'][] = $menus_v;
            }
        }
        View::assign('menu',$tree);
        return View::fetch();
    }

    public function welcome(){
        return View::fetch();
    }

}
